class SRVetBerserker extends SRVeterancy
	abstract;

static function int GetPerkProgressInt( ClientPerkRepLink StatOther, out int FinalInt, byte CurLevel, byte ReqNum )
{
	switch( CurLevel )
	{
	case 0:
		FinalInt = 0;
		break;
	case 1:
		FinalInt = 500000; // 0.5M
		break;
	case 2:
		FinalInt = 1500000; // 1M
		break;
	case 3:
		FinalInt = 3500000; // 2M
		break;
	case 4:
		FinalInt = 6000000; // 2.5M
		break;
	case 5:
		FinalInt = 10000000; // 4M
		break;
	case 6:
		FinalInt = 17000000; // 7M
		break;
	case 7:
		FinalInt = 27000000; // 10M
		break;
	case 8:
		FinalInt = 40000000; // 13M
		break;
	default:
		FinalInt = 60000000 * ( CurLevel - 8 );
	}
	return Min(StatOther.RMeleeDamageStat,FinalInt);
}

static function float GetSelfHealPotency(KFPlayerReplicationInfo KFPRI)
{
	switch( KFPRI.ClientVeteranSkillLevel )
	{
		case 0:
		case 1:
			return 1.0;
		case 2:
		case 3:
			return 1.2;
		case 4:
			return 1.4;
		case 5:
		case 6:
			return 1.6;
		case 7:
		case 8:
			return 1.8;
		case 9:
		default:
			return 2.0;
	}
	return 1.0;
}

static function int AddDamage(KFPlayerReplicationInfo KFPRI, KFMonster Injured, KFPawn DamageTaker, int InDamage, class<DamageType> DmgType)
{
	if( class<KFWeaponDamageType>(DmgType) != none && class<KFWeaponDamageType>(DmgType).default.bIsMeleeDamage
		&& class<DamTypeColdSteel>(DmgType) == none )
	{
		return (1.7 + (0.10 * float(Min(KFPRI.ClientVeteranSkillLevel, 3)))) * Super.AddDamage(KFPRI,Injured,DamageTaker,InDamage,DmgType);
	}
	return Super.AddDamage(KFPRI,Injured,DamageTaker,InDamage,DmgType);
}

static function float GetHeadShotDamMulti(KFPlayerReplicationInfo KFPRI, KFPawn P, class<DamageType> DmgType)
{
	if( class<KFWeaponDamageType>(DmgType) != none && class<KFWeaponDamageType>(DmgType).default.bIsMeleeDamage )
	{
		return FMax(1.0, 0.70 + 0.10 * float(Min(KFPRI.ClientVeteranSkillLevel,9))) * Super.GetHeadShotDamMulti(KFPRI,P,DmgType);
	}

	return Super.GetHeadShotDamMulti(KFPRI,P,DmgType);
}

static function float GetFireSpeedMod(KFPlayerReplicationInfo KFPRI, Weapon Other)
{
	local float ret;

	ret = 1.00;

	if ( ( KFMeleeGun(Other) != none || SRMeleeGun(Other) != none ) && Welder(Other) == none && NewWelder(Other) == none )
	{
		switch( KFPRI.ClientVeteranSkillLevel )
		{
			case 0:
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
				ret = 1.10 + 0.05 * float(KFPRI.ClientVeteranSkillLevel);
				break;
			case 8:
				ret = 1.55;
				break;
			default:
				ret = 1.70;
		}
		
//		ret *= FMax(1.00,1.10/KFPRI.Level.TimeDilation);
	}
	

	return ret * Super.GetFireSpeedMod(KFPRI,Other);
}

static function float GetMeleeMovementSpeedModifier(KFPlayerReplicationInfo KFPRI)
{
	return 0.00;
}

static function float GetMovementSpeedModifier(KFPlayerReplicationInfo KFPRI, KFGameReplicationInfo KFGRI)
{
	local SRPlayerReplicationInfo SRPRI;
	local float ret;
	
	SRPRI = SRPlayerReplicationInfo(KFPRI);
	
	ret = 1.00;
	
	if ( KFWeapon(SRPRI.Controller.Pawn.Weapon).bSpeedMeUp )
	{
		switch ( KFPRI.ClientVeteranSkillLevel )
		{
			case 0:
			case 1:
				ret = 1.16;
				break;
			case 2:
				ret = 1.20;
				break;
			case 3:
				ret = 1.24;
				break;
			case 4:
			case 5:
				ret = 1.28;
				break;
			case 6:
			case 7:
				ret = 1.32;
				break;
			default:
				ret = 1.36;
		}
		
		ret *= FMax(1.00,1.10/SRPRI.Level.TimeDilation);
	}
	
	return ret * Super.GetMovementSpeedModifier(KFPRI,KFGRI);
}

static function int ReduceDamage(KFPlayerReplicationInfo KFPRI, KFPawn Injured, KFMonster DamageTaker, int InDamage, class<DamageType> DmgType)
{
	local float P,FinalDamage,Modifer;
	local SRHumanPawn SRHP;
	
	SRHP = SRHumanPawn(SRPlayerReplicationInfo(KFPRI).Controller.Pawn);
	
	if ( DmgType == class'DamTypeOverdose' )
	{
		Modifer = 1.00;
	}
	else
	{
		P = 0.12 + 0.01 * float(KFPRI.ClientVeteranSkillLevel);
		
		if( FRand() < P && DmgType != class'Fell' )
			return 0; // up to 21% chance to fully ignore damage
		
		if ( DmgType == class'DamTypeVomit' )
		{
			switch ( KFPRI.ClientVeteranSkillLevel )
			{
				case 0:
					Modifer = 0.40;
					break;
				case 1:
					Modifer = 0.35;
					break;
				case 2:
					Modifer = 0.30;
					break;
				case 3:
					Modifer = 0.25;
					break;
				case 4:
					Modifer = 0.20;
					break;
				case 5:
					Modifer = 0.15;
					break;
				case 6:
					Modifer = 0.10;
					break;
				case 7:
					Modifer = 0.05;
					break;
				case 8:
					Modifer = 0.025;
					break;
				default:
					Modifer = 0.000;
			}
		}
		else if ( class<DamTypeBurned>(DmgType) != none || class<DamTypeFlamethrower>(DmgType) != none || class<DamTypeCoolRocket>(DmgType) != none
				|| class<KFWeaponDamageType>(DmgType).default.bIsExplosive )
		{
			switch ( KFPRI.ClientVeteranSkillLevel )
			{
				case 0:
					Modifer = 0.65;
					break;
				case 1:
					Modifer = 0.60;
					break;
				case 2:
					Modifer = 0.575;
					break;
				case 3:
					Modifer = 0.55;
					break;
				case 4:
					Modifer = 0.525;
					break;
				case 5:
					Modifer = 0.50;
					break;
				case 6:
					Modifer = 0.475;
					break;
				case 7:
					Modifer = 0.45;
					break;
				case 8:
					Modifer = 0.425;
					break;
				default:
					Modifer = 0.40;
					break;
			}
		}
		else
		{
			Modifer = 1.00 - Resistance(SRPlayerReplicationInfo(KFPRI));
		}
	}
	
	FinalDamage = InDamage;
	FinalDamage *= Modifer;
	FinalDamage += SRHP.IncomingDamageRemainder;
	InDamage = FinalDamage;
	SRHP.IncomingDamageRemainder = FinalDamage - float(InDamage);
	
	return Super.ReduceDamage(KFPRI,Injured,DamageTaker,InDamage,DmgType);
}

static function float Resistance(SRPlayerReplicationInfo SRPRI)
{
	switch ( SRPRI.ClientVeteranSkillLevel )
	{
		case 0:
			return 0.10; // 10% resistance to all damage
		case 1:
			return 0.15;
		case 2:
			return 0.20;
		case 3:
			return 0.25;
		case 4:
		case 5:
			return 0.30;
		case 6:
		case 7:
		case 8:
			return 0.35;
		default:
			return 0.40; // 40% resistance to all influence
	}
//	return Super.Resistance(SRPRI);
}

static function bool CanBeGrabbed(KFPlayerReplicationInfo KFPRI, KFMonster Other)
{
	return false;
}

static function int ZedTimeExtensions(KFPlayerReplicationInfo KFPRI)
{
	if( KFPRI.ClientVeteranSkillLevel < 9 )
		return Min(KFPRI.ClientVeteranSkillLevel, 4);

	if( KFPRI.ClientVeteranSkillLevel < 10 )
		return 5;
		
	return 6;
}

static function int GetMaxArmor(KFPlayerReplicationInfo KFPRI)
{
	if ( KFPRI.ClientVeteranSkillLevel >= 10 )
		return 200;

	return Super.GetMaxArmor(KFPRI);
}

// Change the cost of particular items
static function float GetCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
	if ( Item == class'ChainsawPickup' || Item == class'KatanaLLIPickup' || Item == class'KatanaPickup'
		|| Item == class'Bal_ClaymoreSwordPickup' || Item == class'BlackChainsawPickup'
		|| Item == class'ScytheNewPickup' || Item == class'FallingStarPickup' )
	{
		return GetDefaultCostScaling(KFPRI.ClientVeteranSkillLevel) * GetProperCostScaling(Item);
	}
	return GetProperCostScaling(Item);
}

// Give Extra Items as default
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{
	super.AddDefaultInventory(KFPRI,P);
	
	if ( KFPRI.ClientVeteranSkillLevel > 2 )
		P.ShieldStrength += 100;
		
	if ( SRPlayerReplicationInfo(KFPRI).bRespawned )
		return;

	if ( KFPRI.ClientVeteranSkillLevel > 2 && KFPRI.ClientVeteranSkillLevel < 9 )
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.BlackChainsaw", GetCostScaling(KFPRI, class'BlackChainsawPickup'));

	if ( KFPRI.ClientVeteranSkillLevel > 5 )
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.Axe1_", GetCostScaling(KFPRI, class'Axe1Pickup'));

	if ( KFPRI.ClientVeteranSkillLevel > 8 )
		KFHumanPawn(P).CreateInventoryVeterancy("ServerPerksV4C.KatanaLLI", GetCostScaling(KFPRI, class'KatanaLLIPickup'));
		
	SRPlayerReplicationInfo(KFPRI).bRespawned = true;
}

static function bool IsPerkTarget(PlayerReplicationInfo PRI, class<Actor> TargetClass)
{
	if ( TargetClass == class'DKScrake' || TargetClass == class'DKBloat' )
	{
		return true;
	}

	return Super.IsPerkTarget(PRI,TargetClass);
}

defaultproperties
{
     CustomLevelInfo="%r extra melee damage|%s faster melee attacks|20% faster melee movement|80% less damage from Bloat Bile|%l resistance to all damage|%d discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Spawn with a Chainsaw and Body Armor|Can't be paralized|Up to 4 Zed-Time Extensions"
     PerkIndex=4
	 BronzeIcon=Texture'SunriseHUD.Icons.Perk_Berserker_Bronze'
	 SilverIcon=Texture'SunriseHUD.Icons.Perk_Berserker_Silver'
	 GoldIcon=Texture'SunriseHUD.Icons.Perk_Berserker_Gold'
     OnHUDIcon=Texture'KillingFloorHUD.Perks.Perk_Berserker'
     OnHUDGoldIcon=Texture'KillingFloor2HUD.Perk_Icons.Perk_Berserker_Gold'
     VeterancyName="Berserker"
     Requirements(0)="Deal %x damage with melee weapons"
     SRLevelEffects(0)="70% extra melee damage|10% faster melee attacks|16% faster melee movement|35% resistance to fire and explosion|60% less damage from Bloat Bile|10% resistance to all damage|12% chance to ignore damage|50% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized"
     SRLevelEffects(1)="80% extra melee damage|15% faster melee attacks|16% faster melee movement|40% resistance to fire and explosion|65% less damage from Bloat Bile|15% resistance to all damage|13% chance to ignore damage|55% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Zed-Time can be extended by killing an enemy while in slow motion"
     SRLevelEffects(2)="90% extra melee damage|20% faster melee attacks|20% faster melee movement|20% extra self heal potency|42.5% resistance to fire and explosion|70% less damage from Bloat Bile|20% resistance to all damage|14% chance to ignore damage|60% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 2 Zed-Time Extensions"
     SRLevelEffects(3)="100% extra melee damage|25% faster melee attacks|24% faster melee movement|20% extra self heal potency|45% resistance to fire and explosion|75% less damage from Bloat Bile|25% resistance to all damage|15% chance to ignore damage|65% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 3 Zed-Time Extensions|Spawn with a Black Chainsaw and Body Armor"
     SRLevelEffects(4)="120% extra headshot melee damage|100% extra body melee damage|30% faster melee attacks|28% faster melee movement|40% extra self heal potency|47.5% resistance to fire and explosion|80% less damage from Bloat Bile|30% resistance to all damage|16% chance to ignore damage|70% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 4 Zed-Time Extensions|Spawn with a Black Chainsaw and Body Armor"
     SRLevelEffects(5)="140% extra headshot melee damage|100% extra body melee damage|35% faster melee attacks|28% faster melee movement|60% extra self heal potency|50% resistance to fire and explosion|85% less damage from Bloat Bile|30% resistance to all damage|17% chance to ignore damage|70% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 4 Zed-Time Extensions|Spawn with a Black Chainsaw and Body Armor"
     SRLevelEffects(6)="160% extra headshot melee damage|100% extra body melee damage|40% faster melee attacks|32% faster melee movement|60% extra self heal potency|52.5% resistance to fire and explosion|90% less damage from Bloat Bile|35% resistance to all damage|18% chance to ignore damage|70% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 4 Zed-Time Extensions|Spawn with an Axe, Black Chainsaw and Body Armor"
	 SRLevelEffects(7)="180% extra headshot melee damage|100% extra body melee damage|45% faster melee attacks|32% faster melee movement|80% extra self heal potency|55% resistance to fire and explosion|95% less damage from Bloat Bile|35% resistance to all damage|19% chance to ignore damage|75% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 4 Zed-Time Extensions|Spawn with an Axe, Black Chainsaw and Body Armor"
	 SRLevelEffects(8)="200% extra headshot melee damage|100% extra body melee damage|55% faster melee attacks|36% faster melee movement|80% extra self heal potency|57.5% resistance to fire and explosion|97.5% less damage from Bloat Bile|35% resistance to all damage|20% chance to ignore damage|75% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 4 Zed-Time Extensions|Spawn with an Axe, Black Chainsaw and Body Armor"
	 SRLevelEffects(9)="220% extra headshot melee damage|100% extra body melee damage|70% faster melee attacks|36% faster melee movement|100% extra self heal potency|60% resistance to fire and explosion|Absolutely immune to Bloat Bile|40% resistance to all damage|21% chance to ignore damage|80% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 5 Zed-Time Extensions|Spawn with an Axe, Katana and Body Armor"
	 SRLevelEffects(10)="220% extra headshot melee damage|100% extra body melee damage|70% faster melee attacks|36% faster melee movement|100% extra self heal potency|60% resistance to fire and explosion|Absolutely immune to Bloat Bile|40% resistance to all damage|21% chance to ignore damage|80% discount on Katana/Chainsaw/Claymore/Scythe/FallingStar|Can't be paralized|Up to 6 Zed-Time Extensions|Spawn with an Axe, Katana and 200 armor|Elite abilities:|70% extra headshot damage with 9mm tactical|Armor Regeneration|Weapon Mastery - Katana headshots stop enemies"
}
